package za.co.dylanjaneke.airdownloader.command
{
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import za.co.dylanjaneke.airdownloader.events.LoadShowsSequenceEvent;
	import za.co.dylanjaneke.airdownloader.events.LoginEvent;
	import za.co.dylanjaneke.airdownloader.events.LogoutEvent;
	import za.co.dylanjaneke.airdownloader.model.StatusPM;

	/**
	 * Author: Dylan Janeke.
	 */
	[Name("loadShowsSequenceCommand")]
	public class LoadShowsSequenceCommand
	{
		[Inject]
		public var statusPM:StatusPM;
		
//		private var timeoutTimer:Timer;
		
		public function handleLoadShowsSequenceEvent(event:LoadShowsSequenceEvent): void
		{
			trace("POES");
			statusPM.status= "masquerading a browser...";
//			timeoutTimer= new Timer(15*1000,1);
//			timeoutTimer.addEventListener(TimerEvent.TIMER, onTimerTimeout);
//			timeoutTimer.start();
				
			GlobalEventDispatcher.raiseEvent(new LogoutEvent());
			GlobalEventDispatcher.raiseEvent(new LoginEvent());
		}
		
		private function onTimerTimeout(event:TimerEvent): void
		{
//			this.timeoutTimer.removeEventListener(TimerEvent.TIMER, onTimerTimeout);
			statusPM.status = "check your internet connection";	
		}
		
		private function complete(): void
		{
//			this.timeoutTimer.stop();
//			this.timeoutTimer.removeEventListener(TimerEvent.TIMER, onTimerTimeout);
		}
	}
}